﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIBlend.WPF.Controls;

namespace AnonsaiWPF.CSharp
{
    /// <summary>
    /// Interaction logic for UndoRedo.xaml
    /// </summary>
    public partial class UndoRedo : Window, IWindow
    {
        public Grid Root
        {
            get
            {
                return this.RootVisual;
            }
        }

        public void SetTheme()
        {
        }
  
        public UndoRedo()
        {
            InitializeComponent();

            this.NumberEditor.Loaded += new RoutedEventHandler(SpinBox_Loaded);
        }

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        void SpinBox_Loaded(object sender, RoutedEventArgs e)
        {
            this.NumberEditor.Value = 1000.00m;

            if (this.NumberEditor != null)
            {
                this.NumberEditor.ValueChanging += new ValueChangingEditorEventHandler(Editor_ValueChanging);
                this.NumberEditor.ValueChanged += new ValueChangedEditorEventHandler(Editor_ValueChanged);
            }

            this.NumberEditor.SpinType = SpinType.SpinValueBeforeDigit;
        }

        void Editor_ValueChanged(object sender, ValueChangedEditorEventArgs args)
        {
            this.Events.Items.Add("ValueChanged: " + args.Value);
        }

        void Editor_ValueChanging(object sender, ValueChangingEditorEventArgs args)
        {
            this.Events.Items.Clear();
            this.Events.Items.Add("ValueChanging: " + "\nNew:" + args.Value + "\nOld:" + this.NumberEditor.LastValue);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.NumberEditor.Redo();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.NumberEditor.Undo();
        }
    }
}
